package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/checkitem")
public class CheckItemContorller {

    @Reference //RPC远程调用 CheckItemService
    private CheckItemService checkItemService;

    /**
     * 分页条件查询
     * @param queryPageBean
     * @return
     */
    @RequestMapping("/findPage")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {

        Result result = checkItemService.queryPage(queryPageBean);

        return result;
    }


    /**
     * 添加检查项
     * @param checkItem
     * @return
     */
    @RequestMapping("/add")
    public Result add(@RequestBody CheckItem checkItem) {

        Result result = checkItemService.addCheckItem(checkItem);

        return result;
    }

    /**
     * 更新检查项
     * @param checkItem
     * @return
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CheckItem checkItem) {
        Result result = checkItemService.updateCheckItem(checkItem);

        return result;
    }

    /**
     * 删除检查项
     * @param id
     * @return
     */
    @RequestMapping("/delete/{id}")
    public Result delete(@PathVariable Integer id) {

       Result result = checkItemService.delete(id);

        return result;
    }


    /**
     * 查询所有检查项 给检查组使用
     * @return
     */
    @RequestMapping("/findAll")
    public Result findAll() {
        Result result = checkItemService.findAll();
        return result;
    }

}
